import ordersApi from '@/api/orders'

const state = {
  typeInfo: [],
  orderInfo: {}
}

const mutations = {
  GET_TYPE_INFO: (state, data) => {
    state.typeInfo = data
  },
  GET_ORDERS_INFO: (state, data) => {
    state.orderInfo = data
  }
}

const actions = {

  async getTypeInfo({ commit, dispatch }) {
    const data = await ordersApi.getTypeInfo()
    commit('GET_TYPE_INFO', data)
  },
  async getOrdersInfo({ commit, dispatch }, pages) {
    const data = await ordersApi.getOrdersInfo(pages)
    commit('GET_ORDERS_INFO', data)
  }

}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
